// This file is part of OpenMOOR, an Open-source simulation program for MOORing
// systems in offshore renewable energy applications.
//
// Created by Lin Chen on Feb 24, 2018.
//
// Copyright 2018 Lin Chen <l.chen.tj@gmail.com> & Biswajit Basu <basub@tcd.ie>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////


#ifndef moorerrror_h
#define moorerrror_h

#include <string>
#include <fstream>
#include <iostream>

namespace moor {
    
enum class ErrorCode
{
    SUCCESS = 0,
    // Mooring file overall error.
    MOORING_FILE_NONEXISTENT,
    MOORING_FILE_ERROR_PARSE,
    MOORING_FILE_NO_CASE,
    MOORING_FILE_INCOMPLETE,
    // Constants error.
    MOORING_FILE_INCOMPLETE_CONSTANTS,
    MOORING_FILE_NAN_CONSTANT,
    // Platform error.
    MOORING_FILE_INCOMPLETE_PLATFORM,
    MOORING_FILE_NAN_PLATFORM_POSITION,
    // Connection error.
    MOORING_FILE_BAD_CONNECTIONS_NUM,
    MOORING_FILE_NO_CONNECTION,
    MOORING_FILE_INCOMPLETE_CONNECTION_DEF,
    MOORING_FILE_NAN_CONNECTION_DEF,
    MOORING_FILE_OUTOFRANGE_CONNECTION_ID,
    MOORING_FILE_UNKNOWN_CONNECTION_TYPE,
    MOORING_FILE_MISSED_REPEATED_CONNECTION_ID,
    // Cable error.
    MOORING_FILE_BAD_CABLES_NUM,
    MOORING_FILE_NO_CABLE_DEF,
    MOORING_FILE_INCOMPLETE_CABLE_DEF,
    MOORING_FILE_NAN_CABLE_DEF,
    MOORING_FILE_OUTOFRANGE_CABLE_ID,
    MOORING_FILE_NAN_CABLE_LENGTH,
    MOORING_FILE_NAN_CABLE_STRUCTPROP_INDEX,
    MOORING_FILE_NAN_CABLE_HYDROPROP_INDEX,
    MOORING_FILE_NAN_CABLE_SEABEDPROP_INDEX,
    MOORING_FILE_NAN_CABLE_CONNECTION_INDEX,
    MOORING_FILE_BAD_CABLE_CONNECTION_INDEX,
    MOORING_FILE_MISSED_REPEATED_CABLE_ID,
    // Structural property error.
    MOORING_FILE_BAD_STRUCTPROPS_NUM,
    MOORING_FILE_NO_STRUCTPROP,
    MOORING_FILE_INCOMPLETE_STRUCTPROP_DEF,
    MOORING_FILE_NAN_STRUCTPROP,
    MOORING_FILE_OUTOFRANGE_STRUCTPROP_ID,
    MOORING_FILE_MISSED_REPEATED_STRUCTPROP_ID,
    // Hydro-property error.
    MOORING_FILE_BAD_HYDROPROPS_NUM,
    MOORING_FILE_NO_HYDROPROP,
    MOORING_FILE_INCOMPLETE_HYDROPROP_DEF,
    MOORING_FILE_NAN_HYDROPROP,
    MOORING_FILE_OUTOFRANGE_HYDROPROP_ID,
    MOORING_FIEL_INCOMPLETE_HYDRO_COEFFICIENTS,
    MOORING_FIEL_NAN_HYDRO_COEFFICIENTS,
    MOORING_FILE_MISSED_REPEATED_HYDROPROP_ID,
    // Seabed property error.
    MOORING_FILE_BAD_SEABEDPROPS_NUM,
    MOORING_FILE_NO_SEABEDPROP,
    MOORING_FILE_INCOMPLETE_SEABEDPROP_DEF,
    MOORING_FILE_NAN_SEABEDPROP,
    MOORING_FILE_OUTOFRANGE_SEABEDPROP_ID,
    MOORING_FILE_MISSED_REPEATED_SEABEDPROP_ID,
    // Current error.
    MOORING_FILE_BAD_CURRENTS_NUM,
    MOORING_FILE_NO_CURRENT,
    MOORING_FILE_INCOMPLETE_CURRENT_DEF,
    MOORING_FILE_NAN_CURRENT,
    MOORING_FILE_OUTOFRANGE_CURRENT_ID,
    MOORING_FILE_BAD_CURRENT_DATA,
    MOORING_FILE_MISSED_REPEATED_CURRENT_ID,
    // Solver error.
    MOORING_FILE_BAD_SOLVERS_NUM,
    MOORING_FILE_NO_SOLVER,
    MOORING_FILE_INCOMPLETE_SOLVER_DEF,
    MOORING_FILE_NAN_SOLVER,
    MOORING_FILE_OUTOFRANGE_SOLVER_ID,
    MOORING_FILE_MISSED_REPEATED_SOLVER_ID,
    // Setting error.
    SETTING_FILE_NONEXISTENT,
    SETTING_FILE_ERROR_PARSE,
    SETTING_FILE_NO_SETTING_NODE,
    SETTING_FILE_NO_SIMULATION_TYPE,
    SETTING_FILE_UNKNOWN_SIMULATION_TYPE,
    SETTING_FILE_NO_MOORING_FILE_DEF,
    SETTING_FILE_NO_SHOOTING_PARA,
    SETTING_FILE_INCOMPLETE_SHOOTING_PARA,
    SETTING_FILE_NAN_SHOOTING_PARA,
    SETTING_FILE_INCOMPLETE_SHOOTING_FAIRLEAD_TOLERANCE,
    SETTING_FILE_NAN_SHOOTING_FAIRLEAD_TOLERANCE,
    SETTING_FILE_BAD_SHOOTING_STIFFNESS,
    SETTING_FILE_BAD_SHOOTING_LOAD,
    SETTING_FILE_NO_RELAXATION_PARA,
    SETTING_FILE_INCOMPLETE_RELAXATION,
    SETTING_FILE_NAN_RELAXATION_PARA,
    SETTING_FILE_BAD_RELAXATION_MASS,
    SETTING_FILE_BAD_RELAXATION_DAMPING,
    SETTING_FILE_BAD_RELAXATION_STIFFNESS,
    SETTING_FILE_BAD_RELAXATION_LOAD,
    SETTING_FILE_NO_MOTION,
    SETTING_FILE_NO_TIME_HISTORY,
    // Mooring input data validation.
    MOORING_INVALID_CONSTANT,
    MOORING_INVALID_CABLE_CURRENT_INDEX,
    MOORING_INVALID_CABLE_SOLVER_INDEX,
    MOORING_INVALID_CABLE_NODE_NUM,
    MOORING_INVALID_CABLE_PROP_ASSOCIATION,
    MOORING_INVALID_CABLE_CONNECTION_INDEX,
    MOORING_INVALID_CABLE_SEGMENT_LENGTH,
    MOORING_INVALID_STRUCT_PROP,
    MOORING_INVALID_HYDRO_COEFFICIENT,
    MOORING_INVALID_SEABED,
    MOORING_INVALID_CURRENT,
    MOORING_INVALID_SOLVER,
    MOORING_INVALID_CABLE_STATE,
    // Setting validation.
    SHOOTING_BAD_PARA,
    RELAXATION_BAD_PARA,
    // Current and motion files.
    CURRENT_FILE_NONEXISTENT,
    CURRENT_FILE_BAD_DATA,
    MOTION_FILE_NONEXISTENT,
    MOTION_FILE_BAD_DATA,
    FORCED_MOTION_BAD_TIME,
    TIME_STEP_TOO_SMALL,
    SINGULAR_MATRIX_SOLVER,
    NAN_CABLE_SOLUTION
};
    
class ErrorCategory
{
public:
    std::string message(ErrorCode err);
};

} // End of namespace moor.

#endif // moorerrror_h
